import storage from '@/util/storage'

class Map extends AMap.Map{
	showInfoWindow = null


	constructor(...props){
		props[1].zooms = [5,16]
		// let userinfo = storage.get("userinfo")
		// props[1].center = [userinfo.org.lng,userinfo.org.lat];
		super(...props);
		// this._tm_init();
	}

	addInfoWindow(a){
		a.onShow(()=>{
			if(this.showInfoWindow){
				this.showInfoWindow.hide();
			}
			this.showInfoWindow = a;
		})
		a.onHide(()=>{
			this.showInfoWindow = null;
		})
	}
	_tm_init(props){
		let geolocation = new AMap.Geolocation({
        enableHighAccuracy: true,//是否使用高精度定位，默认:true
        timeout: 10000,          //超过10秒后停止定位，默认：无穷大
        showButton:false,
        showMarker:false,
        showCircle:false
    });
    this.addControl(geolocation);
    geolocation.getCurrentPosition();
    AMap.event.addListener(geolocation, 'complete', (res)=>{
    	this.setFitView();
    });
	}
}

export default Map;
